<?php
require_once './libs/common.inc.php';
require_once './database/database.inc.php';

$idx = getParam('idx', 0);
$lang = getParam('lang', 'cn');

$smarty->assign('idx', $idx);
$smarty->assign('lang', $lang);

$stmt = ($lang == 'cn') ? $weida_pdo->prepare('SELECT * FROM `content_cn` WHERE idx = ' . $idx) : $weida_pdo->prepare('SELECT * FROM `content_en` WHERE idx = ' . $idx);
$stmt->execute ();
if ($stmt->rowCount() == 1) {
  $result = $stmt->fetch(PDO::FETCH_OBJ);
  $smarty->assign('main', $result->main);
  $smarty->assign('side_header', $result->side_header);
  $smarty->assign('side_dialog', $result->side_dialog);
  $smarty->assign('header', $result->header);
}

$action = getParam('action', 'home');
$smarty->assign('templateContent', $action);
$smarty->display('base.tpl');
?>